const { run } = require("hardhat")
const fs = require("fs")
//调用etherscanAPI验证部署到链上的合约代码 形参包括合约地址以及合约构造器参数
const verifyContract = async (contractAddress, args) => {
    console.log("verifying contract...")
    try {
        await run("verify:verify", {
            address: contractAddress,
            constructorArguments: args,
        })
    } catch (e) {
        if (e.message.toLowerCase().includes("already verified")) {
            console.log("Already verified!")
        } else {
            console.log(e)
        }
    }
}
// const lowSVG = fs.readFileSync("./images/dynamicNFT/sad.svg", {
//     encoding: "utf8",
// })
// const highSVG = fs.readFileSync("./images/dynamicNFT/happy.svg", {
//     encoding: "utf8",
// })
// const args = [
//     "0xedacd53439711643492738d2718cfd7e2100644c",
//     lowSVG,
//     highSVG,
//     false,
// ]
// verifyContract(args)
module.exports = { verifyContract }
